/*
* Copyright (c) 2016 ShopJsp. All Rights Reserved.
 * ============================================================================
 * 版权所有 2011 - 今 北京华宇盈通科技有限公司，并保留所有权利。
 * ----------------------------------------------------------------------------
 * 提示：在未取得SHOPJSP商业授权之前，您不能将本软件应用于商业用途，否则SHOPJSP将保留追究的权力。
 * ----------------------------------------------------------------------------
 * 官方网站：http://www.shopjsp.com
 * ============================================================================
*/
package com.hyyt.shopjsp.product.service.imp;

import com.hyyt.shopjsp.product.dao.ShopShopProCategoryRelationDAO;
import com.hyyt.shopjsp.product.pojo.ShopShopProCategoryRelation;
import com.hyyt.shopjsp.product.service.IShopShopProCategoryRelationService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
* shop_shop_product_category_relation, SHOP_店铺内部商品分类和商品关系
 *
 * @author Robot 14-5-7 上午10:19
 */
@Service
public class ShopShopProCategoryRelationService implements IShopShopProCategoryRelationService {
    private static  final Logger logger = Logger.getLogger(IShopShopProCategoryRelationService.class);

    @Resource
    public ShopShopProCategoryRelationDAO shopShopProCategoryRelationDAO;

    /**
     * 保存SHOP_店铺内部商品分类和商品关系
     *
     * @param shopShopProCategoryRelation SHOP_店铺内部商品分类和商品关系
     * @return 保存后的SHOP_店铺内部商品分类和商品关系
     */
    @Override
    public void saveShopShopProCategoryRelation(ShopShopProCategoryRelation shopShopProCategoryRelation) {
        shopShopProCategoryRelationDAO.insert(shopShopProCategoryRelation);
    }

    /**
     * 更新SHOP_店铺内部商品分类和商品关系
     *
     * @param shopShopProCategoryRelation SHOP_店铺内部商品分类和商品关系
     * @return 更新后的SHOP_店铺内部商品分类和商品关系
     */
    @Override
    public void updateShopShopProCategoryRelation(ShopShopProCategoryRelation shopShopProCategoryRelation) {
        shopShopProCategoryRelationDAO.update(shopShopProCategoryRelation);
    }

    /**
     * 删除指定ID的SHOP_店铺内部商品分类和商品关系
     *
     * @param id SHOP_店铺内部商品分类和商品关系ID
     */
    @Override
    public void deleteShopShopProCategoryRelation(Integer id) {
        shopShopProCategoryRelationDAO.delete(id);
    }

    /**
     * 删除指定ID集合的SHOP_店铺内部商品分类和商品关系
     *
     * @param ids SHOP_店铺内部商品分类和商品关系ID集合
    */
    public void deleteShopShopProCategoryRelation(Collection<Integer> ids){
        shopShopProCategoryRelationDAO.batchDelete(ids);
    }

    /**
     * 根据ID加载一个SHOP_店铺内部商品分类和商品关系
     *
     * @param id SHOP_店铺内部商品分类和商品关系ID
     * @return SHOP_店铺内部商品分类和商品关系
     */
    @Override
    public ShopShopProCategoryRelation loadShopShopProCategoryRelation(Integer id) {
        return shopShopProCategoryRelationDAO.load(id);
    }

    @Override
    public ShopShopProCategoryRelation loadShopProCategoryRelationByParams(Map<String, Object> params) {
        return shopShopProCategoryRelationDAO.load("loadOneByParams",params);
    }

    /**
    * 查询所有的SHOP_店铺内部商品分类和商品关系，通常有最多取30000条记录的限制
    *
    * @return 所有的SHOP_店铺内部商品分类和商品关系，通常有最多取30000条记录的限制
    */
    @Override
    public List<ShopShopProCategoryRelation> queryAllShopShopProCategoryRelation() {
        return shopShopProCategoryRelationDAO.queryAll();
    }

    /**
     * 查询SHOP_店铺内部商品分类和商品关系
     *
     * @param params 查询参数，为key-value形式
     * @return SHOP_店铺内部商品分类和商品关系集合
     */
    @Override
    public List<ShopShopProCategoryRelation> queryShopShopProCategoryRelation(Map<String, Object> params) {
        return shopShopProCategoryRelationDAO.query(params);
    }

    /**
     * 查询SHOP_店铺内部商品分类和商品关系
     *
     * @param params   查询参数，没有则传null,分页参数key为“sortColumns”
     * @param startRow 起始行数（不含起始行的数据）
     * @param rowSize  要查询记录数
     * @return SHOP_店铺内部商品分类和商品关系集合
     */
    @Override
    public List<ShopShopProCategoryRelation> queryShopShopProCategoryRelation(Map<String, Object> params, int startRow, int rowSize) {
        return shopShopProCategoryRelationDAO.query(params, startRow, rowSize);
    }

    /**
     * 统计SHOP_店铺内部商品分类和商品关系
     *
     * @param params 查询参数，没有则传null,分页参数key为“sortColumns”
     * @return 结果集记录数
     */
    @Override
    public int countShopShopProCategoryRelation(Map<String, Object> params) {
        return shopShopProCategoryRelationDAO.count(params);
    }

    @Override
    public void updateByProductId(Map<String, Object> params) {
        shopShopProCategoryRelationDAO.load("updateByProductId",params);
    }
}
